package com.cz.nongyetongv5.utils;
 

 
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; 

public class Session { 
	
	 	
	 private Context context=null;
	 private String key;
     public Session(Context cont,String ke){
   	    context=cont;
   	    key=ke;
     }
    
    private SharedPreferences getSp(){
    	Context ctx =context;  
    	 
   	         return ctx.getSharedPreferences(key,Context.MODE_PRIVATE);
    	 
        }
    

      public String getString() {
		SharedPreferences sp=getSp();
    	if(sp==null)return "error";
    	 else 
		 return  getSp().getString(key,"");
	}

    public boolean setString(String string) {
		SharedPreferences sp=getSp();
		if(sp==null){
			return false;
			
		}else{
		Editor editor = getSp().edit();
		    editor.putString(key, string);
         editor.commit();
         return true;
		}
	}
    
   	 
     
}
